#include "model/sun.h"

Sun::Sun(GLuint texture_id, float radius) {
    _shader.texture_id = texture_id;
    createIcosphereMesh(_mesh, 2);
    set_radius(radius);
    _mesh.update_buffer();
}

void Sun::set_tempreture(float t) {
    _shader.set_tempreture(t);
}

void Sun::set_radius(float radius_new) {
    for (int i = 0; i < this->_mesh.vertices.size(); i++) {
        this->_mesh.vertices[i] *= radius_new / this->radius;
    }
    this->radius = radius_new;
}

float Sun::get_radius() {
    return this ->radius;
}

void Sun::render(glm::mat4 viewMat, glm::mat4 projMat) {
    auto modelMat = getTransMat();
    _shader.render(_mesh, modelMat, viewMat, projMat);
}